package job.Util;



import job.pojo.HoseholdUsers;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;

public class HoseholdService {
    private HoseholdDao dao = new HoseholdDao();

    public ArrayList<HoseholdUsers> getAllHouseholdUsers() {
        try {
            return dao.findAllHouseholdUsers();
        } catch (SQLException e) {
            e.printStackTrace();
            return new ArrayList<>();
        }
    }

    public ArrayList<String> getHotelNames() {
        try {
            return dao.findAllHotelNames();
        } catch (SQLException e) {
            e.printStackTrace();
            return new ArrayList<>();
        }
    }

    public boolean addUserToHousehold(String hname, String uname, String froms, Date sdate) {
        try {
            return dao.addHouseholdUser(hname, uname, froms, sdate);
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }

    // ✅ 新增：按酒店名查询入住列表
    public ArrayList<HoseholdUsers> getHouseholdUsersByHotelName(String hotelName) {
        try {
            return dao.findHouseholdUsersByHotelName(hotelName);
        } catch (SQLException e) {
            e.printStackTrace();
            return new ArrayList<>();
        }
    }
}
